#include "widget.h"
#include "ui_widget.h"

#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    //先获取到两个输入框的时间是什么
    QDateTime timeOld=ui->dateTimeEdit->dateTime();
    QDateTime timeNew=ui->dateTimeEdit_2->dateTime();
    qDebug()<<timeOld<<timeNew<<endl;
    //计算机日期的差值
    //int days=timeOld.daysTo(timeNew);
    int seconds=timeOld.secsTo(timeNew);
    //要把秒数换算为小时
    int hours=(seconds/3600)%24;
    int days=(seconds/3600)/24;
    ui->label->setText(QString::number(days)+QString("天零")+QString::number(hours)+QString("小时"));
}
